/*
This file is part of quIRC bot

    quIRC bot is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    quIRC bot is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with quIRC bot.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IRC_H
#define IRC_H
#pragma once

#include "include.h"

typedef struct IRC_INFO
{
	int auth;
	int sock;
	int connected;
	char* server;
	char* channel;
	char* alias;
	char* password;
} IRC_I;

class IRC_CONNECTION
{
private:
	WSADATA wsa;
	IRC_INFO info;

	bool	IsConnected;

public:
	hostent* DomainHost;
	in_addr	 DomainAddr;
	sockaddr_in insock;

	char*	argsv[256];			// *argv[] for irc
	int		argsc;				// argc for irc


	IRC_CONNECTION();
	~IRC_CONNECTION();

	bool IRCInit();
	bool IRCClose();

	int irc_send(const char* format, ...);
	char* irc_recv();

	bool ResolveDomain(const char* DomainName);
	bool JoinServer(const char* Server, int Port, const char* Pass, const char* Channel, const char* NickName, const char* User);
	bool JoinChannel(const char* Channel);

	int	MessageLoop();
};

extern void cmd_help(IRC_CONNECTION* m_irc, LPVOID parameters, LPVOID from),
		cmd_about(IRC_CONNECTION* m_irc, LPVOID parameters, LPVOID from),	
		cmd_slap(IRC_CONNECTION* m_irc, LPVOID parameters, LPVOID from),
		cmd_join(IRC_CONNECTION* m_irc, LPVOID parameters, LPVOID from),
		cmd_setname(IRC_CONNECTION* m_irc, LPVOID parameters, LPVOID from),
		cmd_part(IRC_CONNECTION* m_irc, LPVOID parameters, LPVOID from), 
		cmd_quit(IRC_CONNECTION* m_irc, LPVOID parameters, LPVOID from);

struct COMMANDLIST	// info about our commands
{
	const char* Command;
	const char* Usage;
	void (*exec_command)(IRC_CONNECTION* m_irc, LPVOID parameters, LPVOID from);
};

#endif